package com.xinz.srmi.impl.serialization;

public class PackSerialer {
	static class IntegerSerialer extends Serialer{
		@Override
		public void read(Accessor accessor, BeanInputStream in)
				throws Exception {
			accessor.set(in.readInt());
		}
		@Override
		public void write(Accessor accessor, BeanOutputStream out)
				throws Exception {
			out.writeInt((Integer)accessor.get());
		}
		@Override
		public Class getType() {
			return Integer.class;
		}
	}
	static class FloatSerialer extends Serialer{
		@Override
		public void read(Accessor accessor, BeanInputStream in)
				throws Exception {
			accessor.set(in.readFloat());
		}
		@Override
		public void write(Accessor accessor, BeanOutputStream out)
				throws Exception {
			out.writeFloat((Float)accessor.get());
		}
		@Override
		public Class getType() {
			return Float.class;
		}
	}
	static class ShortSerialer extends Serialer{
		@Override
		public void read(Accessor accessor, BeanInputStream in)
				throws Exception {
			accessor.set(in.readShort());
		}
		@Override
		public void write(Accessor accessor, BeanOutputStream out)
				throws Exception {
			out.writeShort((Short)accessor.get());
		}
		@Override
		public Class getType() {
			return Short.class;
		}
	}
	static class BooleanSerialer extends Serialer{
		@Override
		public void read(Accessor accessor, BeanInputStream in)
				throws Exception {
			accessor.set(in.readBoolean());
		}
		@Override
		public void write(Accessor accessor, BeanOutputStream out)
				throws Exception {
			out.writeBoolean((Boolean)accessor.get());
		}
		@Override
		public Class getType() {
			return Boolean.class;
		}
	}

	static class LongSerialer extends Serialer{
		@Override
		public void read(Accessor accessor, BeanInputStream in)
				throws Exception {
			accessor.setLong(in.read());
		}
		@Override
		public void write(Accessor accessor, BeanOutputStream out)
				throws Exception {
			out.writeLong((Long)accessor.get());
		}
		@Override
		public Class getType() {
			return Long.class;
		}
	}

	static class DoubleSerialer extends Serialer{
		@Override
		public void read(Accessor accessor, BeanInputStream in)
				throws Exception {
			accessor.set(in.readDouble());
		}
		@Override
		public void write(Accessor accessor, BeanOutputStream out)
				throws Exception {
			out.writeDouble((Double)accessor.get());
		}
		@Override
		public Class getType() {
			return Double.class;
		}
	}

	static class CharacterSerialer extends Serialer{
		@Override
		public void read(Accessor accessor, BeanInputStream in)
				throws Exception {
			accessor.set(in.readChar());
		}
		@Override
		public void write(Accessor accessor, BeanOutputStream out)
				throws Exception {
			out.writeChar((Character)accessor.get());
		}
		@Override
		public Class getType() {
			return Character.class;
		}
	}
	static class ByteSerialer extends Serialer{
		@Override
		public void read(Accessor accessor, BeanInputStream in)
				throws Exception {
			accessor.set(in.readByte());
		}
		@Override
		public void write(Accessor accessor, BeanOutputStream out)
				throws Exception {
			out.writeByte((Byte)accessor.get());
		}
		@Override
		public Class getType() {
			return Byte.class;
		}
	}
}



